 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="th.co.mfec.agi.common.constant.CommonConstant"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="cd" uri="/WEB-INF/tld/commondisplay-tag.tld"%>
<div id="dialog" title="" class="ui-state-error">
	<p>
		<span id="dialogicon" class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span>
		<span id="dialogdetail"></span>
	</p>
</div>
<script type="text/javascript">
$j("#dialog").dialog({
	//bgiframe: true,
	modal: true,
	autoOpen: false,
	width: 500,
	buttons: {
		Ok: function() {
			$j(this).dialog('close');
		}
	}
});

$j("#dialoginfo").click(function(e){
	$j("#dialoginfo").fadeOut(1000);
});
//author: Wirojsin Trakuldon
//description : isErrorPage parameter for error.jsp only
function showResponse(responseText, statusText, isErrorPage) {
	//error/warning/info
	eval( "var o = " + responseText + "" );
	var status = o.status;
	var content = "";
	if (o.messageList != null) {
		for (var i=0; i<o.messageList.length; i++) {
			content += "<strong>" + o.messageList[i].messageCode + "</strong>"+" : "+o.messageList[i].messageText+"<br/>";
		}
	}
	if(isErrorPage)
	{
		iconClass = 'ui-icon ui-icon-circle-check';
		if (status == '<%= CommonConstant.MESSAGE_TYPE_ERROR %>' ) {
			iconClass = 'ui-icon ui-icon-alert';
		} else if (status == '<%= CommonConstant.MESSAGE_TYPE_WARNING %>') {
			iconClass = 'ui-icon ui-icon-info';
		}
		
		$j("#dialoginfo").html(
				'<div class="ui-widget ui-widget-custom">'
			+	'<div id="dialoginfoborder" class="ui-state-highlight ui-corner-all" style="padding:10px 5px 5px 5px; vertical-align:middle;">'
			+	'<p><span id="dialoginfoicon" class="ui-icon ui-icon-circle-check" style="float: left; margin-right: .3em;"></span>'
			+	content + '</p>'
			+	'</div>'
			+	'</div>'
			+	'<br />'
			);

		if (status == '<%= CommonConstant.MESSAGE_TYPE_ERROR %>' ) {
			$j("#dialoginfoborder").addClass("ui-state-error").removeClass("ui-state-highlight");
			$j("#dialoginfoicon").addClass("ui-icon-alert").removeClass("ui-icon-circle-check");
		} else if (status == '<%= CommonConstant.MESSAGE_TYPE_WARNING %>') {
			//$j("#dialoginfoborder").addClass("ui-state-error").removeClass("ui-state-highlight");
			$j("#dialoginfoicon").addClass("ui-icon-info").removeClass("ui-icon-circle-check");
		}
		
		//skip the rest of code
		return true;
	}
	
	if (status == '<%= CommonConstant.MESSAGE_TYPE_ERROR %>' ) {
		$j("#dialogicon").attr('class', 'ui-icon ui-icon-alert');
		$j("#dialogdetail").html(content);
		$j('#dialog')
			.addClass('ui-state-error')
			.dialog('option' , 'title', status)
			.dialog('open');
	} else if (status == '<%= CommonConstant.MESSAGE_TYPE_WARNING %>') {
		$j("#dialogicon").attr('class', 'ui-icon ui-icon-info');
		$j("#dialogdetail").html(content);
		$j('#dialog')
			.removeClass('ui-state-error')
			.dialog('option' , 'title', status)
			.dialog('open');
	} else {
		$j("#dialoginfo").show();
		$j("#dialoginfo").html(
				'<div class="ui-widget ui-widget-custom">'
			+	'<div class="ui-state-highlight ui-corner-all" style="padding:10px 5px 5px 5px; vertical-align:middle;">'
			+	'<p><span class="ui-icon ui-icon-circle-check" style="float: left; margin-right: .3em;"></span>'
			+	content + '</p>'
			+	'</div>'
			+	'</div>'
			+	'<br />'
			);
	}

	//$j("#contentArea").focus();
}
<c:if test="${sessionScope.SESSION_STATUS_KEY != null}">
showResponse('{'
	+'"status":"${sessionScope.SESSION_STATUS_KEY}",'
	+'"messageList":${cd:escJS(sessionScope.SESSION_MESSAGE_KEY)}}',
	'',
	'<c:out value="${requestScope.IS_ERROR_PAGE}" default="false" />');
<c:remove var="SESSION_STATUS_KEY" scope="session" />
<c:remove var="SESSION_MESSAGE_KEY" scope="session" />
</c:if>

//Add by Poo for login module.
<c:if test="${(!(sessionScope.alarmChangePassword eq 'Y')) and sessionScope.firstSetPassword eq 'Y'}">
	alert(message(MS_EX022,[]));
	$j("#newPassword").focus();
	<c:remove var="firstSetPassword" scope="session" />
</c:if>

</script>

<c:if test="${sessionScope.alarmChangePassword eq 'Y'}">
<script language="javascript">
	$j("#alarmConfirmForm").ready(function()
	{
		//var result = confirm(message(MS_EX017,["Pre Expire"]));
		var result = confirm("Password Pre Expire. Please reset new password.");
		var changePasswordConfirm = result?'Y':'N';
		$j("#changePasswordConfirm").val(changePasswordConfirm);
		document.forms[0].submit();
	});
</script>
<form id="alarmConfirmForm" action="alarmConfirm-login.htm" method="get">
	<s:hidden id="changePasswordConfirm" name="changePasswordConfirm" value="" />
</form>
<c:remove var="alarmChangePassword" scope="session" />
</c:if>

